<?php

namespace app\common\model;

use think\Db;
use think\Model;

class HostModuleRelation extends Model
{
    /**
     * @name 验证字段是否存在
     * @param $field
     * @author wx
     * @date 2019/12/4 11:27
     */
    function checkField($field)
    {
        $dbConfig = config('database.');
        $tableName = $dbConfig['prefix'].'host_module_relation';
        $sql = "select count(*) as num from information_schema.columns where table_name = '$tableName' and column_name = '$field'";

        $res = Db::query($sql);

        $fieldNum = $res[0]['num'];

        return $fieldNum;
    }
}